﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using Zeus.Thunder.Core;

namespace SharpTrainer.NetWork
{
    class SmtpClientTest : ITestCase
    {
        public void Run()
        {
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    SmtpClient client = new SmtpClient();
                    client.Host = "smtp.163.com";
                    client.UseDefaultCredentials = true;
                    client.Credentials = new System.Net.NetworkCredential("masterhaku", "fuckwgm");
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.Timeout = 10000; //timeout

                    MailMessage mm = new MailMessage();
                    mm.Sender = new MailAddress("masterhaku@163.com", "Test");
                    mm.From = new MailAddress("masterhaku@163.com", "Master HaKu");
                    //mm.To.Add(new MailAddress("davidgjy@163.com", "David"));
                    mm.To.Add(new MailAddress("gjy@binpit.com", "gjy"));
                    //mm.CC.Add(new MailAddress("dan@domain.com", "Dan"));
                    mm.Subject = "Hello!";
                    mm.Body = "Hi there. Here's the document!";
                    mm.IsBodyHtml = false;
                    mm.Priority = MailPriority.High;
                    Attachment a = new Attachment("E:\\tianxia5_sdk_docu 2.doc", System.Net.Mime.MediaTypeNames.Text.RichText);
                    mm.Attachments.Add(a);
                    client.Send(mm);

                    Console.WriteLine("EMail Send Successful!");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception: {0}", ex.Message);
                }
            }
        }
    }
}
